// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Fluent;
using Elastic.Clients.Elasticsearch.Serialization;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch.Security;

public sealed partial class ApplicationPrivileges
{
	/// <summary>
	/// <para>
	/// The name of the application to which this entry applies.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("application")]
	public string Application { get; set; }

	/// <summary>
	/// <para>
	/// A list of strings, where each element is the name of an application privilege or action.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("privileges")]
	public ICollection<string> Privileges { get; set; }

	/// <summary>
	/// <para>
	/// A list resources to which the privileges are applied.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("resources")]
	public ICollection<string> Resources { get; set; }
}

public sealed partial class ApplicationPrivilegesDescriptor : SerializableDescriptor<ApplicationPrivilegesDescriptor>
{
	internal ApplicationPrivilegesDescriptor(Action<ApplicationPrivilegesDescriptor> configure) => configure.Invoke(this);

	public ApplicationPrivilegesDescriptor() : base()
	{
	}

	private string ApplicationValue { get; set; }
	private ICollection<string> PrivilegesValue { get; set; }
	private ICollection<string> ResourcesValue { get; set; }

	/// <summary>
	/// <para>
	/// The name of the application to which this entry applies.
	/// </para>
	/// </summary>
	public ApplicationPrivilegesDescriptor Application(string application)
	{
		ApplicationValue = application;
		return Self;
	}

	/// <summary>
	/// <para>
	/// A list of strings, where each element is the name of an application privilege or action.
	/// </para>
	/// </summary>
	public ApplicationPrivilegesDescriptor Privileges(ICollection<string> privileges)
	{
		PrivilegesValue = privileges;
		return Self;
	}

	/// <summary>
	/// <para>
	/// A list resources to which the privileges are applied.
	/// </para>
	/// </summary>
	public ApplicationPrivilegesDescriptor Resources(ICollection<string> resources)
	{
		ResourcesValue = resources;
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		writer.WritePropertyName("application");
		writer.WriteStringValue(ApplicationValue);
		writer.WritePropertyName("privileges");
		JsonSerializer.Serialize(writer, PrivilegesValue, options);
		writer.WritePropertyName("resources");
		JsonSerializer.Serialize(writer, ResourcesValue, options);
		writer.WriteEndObject();
	}
}